﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LCA.Admin.FormControls
{
    public partial class InlineXhtmlEditor : System.Web.UI.UserControl
    {
        protected string _currentStringValue = null;

        public string Xhtml
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (string.IsNullOrEmpty(this.Xhtml) == false)
                {
                    _currentStringValue = this.Xhtml;
                }
                else
                {
                    _currentStringValue = "<html xmlns='http://www.w3.org/1999/xhtml'>\n\t<head></head>\n\t<body>\n\t</body>\n</html>";
                }
                //_currentStringValue = HttpContext.Current.Server.UrlEncode(_currentStringValue).Replace("+", "%20");
            }
            else
            {
                _currentStringValue = Request.Form[this.ClientID];
                //this.Xhtml = HttpContext.Current.Server.UrlDecode(_currentStringValue).Replace("&nbsp;", "&#160;");
                _currentStringValue = HttpContext.Current.Server.UrlDecode(_currentStringValue);
                this.Xhtml = _currentStringValue == null ? null : _currentStringValue.Replace("&nbsp;", "&#160;");
            }
        }
    }
}